package com.itcast.demo_one.kotlin

fun main(){
    val stu1 = Student(1001, "张三", 18, "软件工程", 90)
    val stu2 = Student(1002, "李四", 19, "软件工程", 80)
    val stu3 = Student(1003, "王五", 20, "软件工程", 70)

    // 1.实现了toString()方法
    println(stu1)
    println(stu2)
    println(stu3)

    // 2.实现了equals()方法
    println(stu1.equals(stu2))

    // 3.实现了copy方法
    val stu4 = stu1.copy(name = "赵六", age = 20)
    println(stu4)

    // 4.实现解构
    val (id, name, age, className, score) = stu1
    println("id: $id, name: $name, age: $age, className: $className, score: $score")
}


// 数据类
data class Student(
    // 属性
    val id : Int,
    var name: String,
    var age: Int,
    var className:String,
    var score: Int
)